import request from '../utils/request';

export const getOrderList = async (data: {statue: number, open_id: string}) => {
  const res = await request<any[]>({
    url: '/order/get',
    method: 'GET',
    data
  });
  return res.data || [];
};

export const getOrderDetail = async (id: string) => {
  const res = await request<any[]>({
    url: '/order/get',
    method: 'GET',
    data: { id }
  });
  return res.data?.[0] || {};
};

export const payOrder = async (id: string) => {
  const res = await request<any[]>({
    url: '/order/pay',
    method: 'GET',
    data: { id }
  });
  return res;
};

export const cancelOrder = async (id: string) => {
  const res = await request<any[]>({
    url: '/order/cancel',
    method: 'GET',
    data: { id }
  });
  return res;
};

export const addOrder = async (data: any) => {
  const res = await request<any[]>({
    url: '/order/create',
    method: 'POST',
    data
  });
  return res;
};